package com.example.websocketdemo.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.websocketdemo.config.WebSocketTest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/Connect")
public class ConnectController {

    @GetMapping("/one")
    public void one() throws IOException {
        JSONObject jsonObject_one = new JSONObject();
        jsonObject_one.put("instruction","resetpoi");
        WebSocketTest.sendInfo(jsonObject_one.toJSONString(), "connect");

        JSONObject jsonObject = new JSONObject();
        JSONObject json = new JSONObject();
        jsonObject.put("instruction","switchweb");
        json.put("webindex","1");
        jsonObject.put("param",json);
        WebSocketTest.sendInfo(jsonObject.toJSONString(), "connect");
    }
    @GetMapping("/two")
    public void two() throws IOException {

        JSONObject jsonObject_one = new JSONObject();
        jsonObject_one.put("instruction","resetpoi");
        WebSocketTest.sendInfo(jsonObject_one.toJSONString(), "connect");

        JSONObject jsonObject = new JSONObject();
        JSONObject json = new JSONObject();
        jsonObject.put("instruction","switchweb");
        json.put("webindex","2");
        jsonObject.put("param",json);
        WebSocketTest.sendInfo(jsonObject.toJSONString(), "connect");
    }
    @GetMapping("/three")
    public void three() throws IOException {
        JSONObject jsonObject_one = new JSONObject();
        jsonObject_one.put("instruction","resetpoi");
        WebSocketTest.sendInfo(jsonObject_one.toJSONString(), "connect");

        JSONObject jsonObject1 = new JSONObject();
        JSONObject json1 = new JSONObject();
        jsonObject1.put("instruction","switchweb");
        json1.put("webindex","3");
        jsonObject1.put("param",json1);
        WebSocketTest.sendInfo(jsonObject1.toJSONString(), "connect");
        JSONObject jsonObject = new JSONObject();
        JSONObject json = new JSONObject();
        jsonObject.put("instruction","showpoi");
        json.put("showtype","group");
        json.put("poigroup","contingencymanagement");
        json.put("poitype","web");
        jsonObject.put("param",json);
        WebSocketTest.sendInfo(jsonObject.toJSONString(), "connect");
    }
//    @GetMapping("/four")
//    public void four(){
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("MenuName","MainMenu");
//        jsonObject.put("ButtonName","four");
//        WebSocketTest.sendInfo(jsonObject.toJSONString(), "connect");
//    }
}
